/**
 * 
 */

var services = new Array();

var appsDomain = "[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}";
var emailAddress = "[a-zA-Z0-9._%+-]+%40[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}";

var mailUrlStart = "^http(s)?:\/\/mail.google.com\/(mail|mail\/u\/0|a\/"
		+ appsDomain + ")";
services.push({
	name : "Gmail (Apps)",
	id : "GMAIL_APPS",
	regex : new RegExp(mailUrlStart
			+ "\/(?!(.*mailto|.*&view=att&.*&disp=inline)).*"),
	frontPageRegex : new RegExp(mailUrlStart
			+ "\/\\?(hl=[a-z]{2}&)?tab=[a-z]{2}$")
});

var calendarUrlStart = "^http(s)?:\/\/www.google.com\/calendar(\/b\/0|\/hosted\/"
		+ appsDomain + ")?";
services.push({
	name : "Calendar (Apps)",
	id : "CALENDAR_APPS",
	regex : new RegExp(calendarUrlStart + "\/.*"),
	frontPageRegex : new RegExp(calendarUrlStart
			+ "\/render\\?(hl=[a-z]{2}&)?tab=[a-z]{2}"
			+ "(&auth=[-_0-9a-zA-Z]+&husr=" + emailAddress + ")?$")
});

services.push({
	name : "Documents (Apps)",
	id : "DOCS_APPS",
	regex : new RegExp("^http(s)?:\/\/docs.google.com\/a\/" + appsDomain
			+ "\/.*"),
	frontPageRegex : new RegExp("^http(s)?:\/\/docs.google.com\/a\/"
			+ appsDomain + "\/\\?(hl=[a-z]{2}&)?tab=[a-z]{2}(&authuser="
			+ appsDomain + ")?$")
});

services.push({
	name : "Groups (Apps)",
	id : "GROUPS_APPS",
	regex : new RegExp("^http(s)?:\/\/groups.google.com\/a\/" + appsDomain
			+ "\/.*"),
	frontPageRegex : new RegExp("^http(s)?:\/\/groups.google.com\/a\/"
			+ appsDomain + "\/\\?tab=[a-z]{2}$")
});
